package Exercise;
//将int数组内容按照一定格式以字符串返回
public class String_5 {
    public static void main(String[] args) {
        int[] arr = {1,2,3};
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        //添加元素
        for (int i = 0; i < arr.length; i++) {
            if(i!=arr.length-1)
                sb.append(arr[i]).append(",");
            else
                sb.append(arr[i]);
        }
        sb.append("]");
        //转变为String
        String sr  = sb.toString();
        System.out.println(sr);
    }
}
